<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/main.css" />
    <script type="text/javascript" src="../script/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/mobile.js"></script>
    <script type="text/javascript" src="../script/public.js"></script>
    <script type="text/javascript" src="../script/app.js"></script>
    <title>消息</title>
</head>
<body>
<div class="zhifu_cgs">
    <div>
        <!--<img src="../image/jiant_rg.png" alt="">-->
        <p>消息</p>
    </div>
</div>
<div class="ims_list">
    <ul id="mge">
        
    </ul>
</div>
<div class="ind_nalis">

    <ul>
        <li onclick="open_winrs('index','index.html');">
                <span>
                    <img class="shoede_na" src="../image/shouye1.png" alt="">
                    <img src="../image/shouye.png" alt="">
                    <p>首页</p>
                </span>
        </li>
        <li onclick="open_winrs('resrtion','wode_yudin.html');">
                <span>
                    <img class="shoede_na" src="../image/dind1.png" alt="">
                    <img src="../image/dind.png" alt="">
                    <p>预订</p>
                </span>
        </li>
        <li class="chek_nvts" onclick="open_winrs('imgsg','xiaoxi.html');">
                <span class="xiaoxx" id="unread">
                    <img class="shoede_na" src="../image/xiaox1.png" alt="">
                    <img src="../image/xioax.png" alt="">
                    <p>消息</p> 
                </span>
        </li>
        <li onclick="open_winrs('myslf','wode.html');">
                <span>
                    <img class="shoede_na" src="../image/wode1.png" alt="">
                    <img src="../image/wode.png" alt="">
                    <p>我的</p>
                </span>
        </li>
    </ul>
</div>
</body>
<script>
    $(function () {

        $(document).on("click",".dind_lsit ul li",function () {

            open_winrs('xiaoxi_for','xiaoxi_xiangq.html');
        })

    })
</script>
<script type="text/javascript">
    window['adaptive'].desinWidth = 750;
    window['adaptive'].baseFont = 28;
    window['adaptive'].maxWidth = 750;
    window['adaptive'].init();

    // var page=1;

    apiready = function () {
       


        $api.fixStatusBar($api.dom('.header'));
        api.addEventListener({
            name: 'keyback'
        }, function(ret, err){
            api.closeWidget();
        });


        toDoRequest();

        api. addEventListener({name:'scrolltobottom'}, function(ret, err){
            
            toDoRequest();

        });



        
    }

    function toDoRequest(){
        var p = {uid:id};
        api.ajax({
            url:webSiteUrl+'/App/User/message',
            method:'post',
            data:{
                values:p
            }
        },function(ret,err){
             

            if (ret.code == 200) {
               var list = ret.data.message;
              
               var sid = api.deviceId;
               html = '';
               if (list != null) {
                   for (var i=0 ; i < list.length ; i++) {

                       if(list[i].see_status == 0){
                            html += ' <li onclick="shop('+list[i].id+');"><span><p>'+list[i].days+'</p><i>'+list[i].title+'</i></span><img src="../image/dor.png" alt=""></li>';
                            
                       }else if(list[i].see_status == 1){
                            html += '<li class="yidu" onclick="shop('+list[i].id+');"><span><p>'+list[i].days+'</p><i>'+list[i].title+'</i></span></li>';
                            
                       }
                    }
                }

                
                $('#mge').html(html);
                
                if (ret.data.unread != 0 ) {
                    $('#unread').html('<img class="shoede_na" src="../image/xiaox1.png" alt=""><img src="../image/xioax.png" alt=""><p>消息</p><em>'+ret.data.unread+'</em>');
                }else{
                    $('#unread').html('<img class="shoede_na" src="../image/xiaox1.png" alt=""><img src="../image/xioax.png" alt=""><p>消息</p>');
                }

                
                
                
               
            }else{
                alert(ret.msg);
            }
        });
    }

    //详情
    function shop(mid){

        var m = {uid:id,id:mid};
        api.ajax({
            url:webSiteUrl+'/App/user/message_shop',
            method:'post',
            data:{
                values:m
            }
        },function(ret,err){
           
            if(ret.code == 200){

                api.openWin({
                    name: 'xiaoxi_shop',
                    url: './xiaoxi_xiangq.html',
                    reload:true,
                    pageParam: {
                        days: ret.data.days,
                        hour:ret.data.hour,
                        content:ret.data.content,
                        icon:ret.data.icon
                    }
                });
            }else{
                alert(ret.msg);
            }
        });
    }
</script>
</html>